#ifndef SERVERWINDOW_H
#define SERVERWINDOW_H

#include <QMainWindow>
#include <QtNetwork>

#include "client.h"

namespace Ui {
class ServerWindow;
}

class ServerWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit ServerWindow(QWidget *parent = 0);
    ~ServerWindow();

    void sendToAll(const QString &message);
    void sendToAllExceptCurrent(QTcpSocket *socket, const QString &message);
    QByteArray AssembleMessage(QString message);

private slots:
    void newConnexion();
    void dataReceived();
    void clientDisconnect();
    
private:
    Ui::ServerWindow *ui;

    QTcpServer *server;
    QList<Client *> clients;
    //QList<QTcpSocket *> clients;
    quint16 messageSize;
    int connectedClients;

    Client* findClient(QTcpSocket* socket);

};

#endif // SERVERWINDOW_H
